package com.winit.config.web;


import com.winit.common.base.web.BaseController;
import com.winit.config.manager.LocalConfigManager;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@Api(value = "feature", tags = {"config"}, description = "config")
@RequestMapping(value = "/api/v1/config")
public class ConfigController extends BaseController {

    private static Logger logger = LoggerFactory.getLogger(ConfigController.class);

    @Autowired
    private LocalConfigManager localConfigManager;

    @ResponseStatus(HttpStatus.OK)
    @ApiOperation(value = "根据id获取指定config")
    @RequestMapping(value = "/get", method = RequestMethod.GET)
    @ResponseBody
//    @Cacheable(cacheNames = {"tree_feature"}, key = "#reqId  + '-' +  #sys + '-' + #featureId + '-' + #withChildren + '-' + #withAttrs")
    public Map get( @ApiParam(value = "configId", required = true) @RequestParam(value = "configId", required = true) String configId) {
        return this.getRtn("0", "success", this.localConfigManager.getConfigById(configId));
    }





}
